package com.dt.platform.generator.module.ops;

import com.dt.platform.constants.db.OpsTables;
import com.dt.platform.constants.enums.ops.OpsTaskStatusEnum;
import com.dt.platform.constants.enums.ops.OpsTaskStepStatusEnum;
import com.dt.platform.generator.config.Config;
import com.dt.platform.ops.page.TaskStepLogPageController;
import com.dt.platform.ops.page.TaskStepPageController;
import com.dt.platform.proxy.ops.TaskStepLogServiceProxy;
import com.dt.platform.proxy.ops.TaskStepServiceProxy;
import com.github.foxnic.generator.config.WriteMode;

public class TaskStepGtr extends BaseCodeGenerator{


    public TaskStepGtr() {
        super(OpsTables.OPS_TASK_STEP.$TABLE,"748459098852294661");
    }

    public void generateCode() throws Exception {
        System.out.println(this.getClass().getName());

        cfg.view().field(OpsTables.OPS_TASK_STEP.ID).table().hidden(true);
        cfg.view().field(OpsTables.OPS_TASK_STEP.ID).basic().hidden();

        cfg.view().field(OpsTables.OPS_TASK_STEP.NAME).search().fuzzySearch();

        cfg.view().search().inputLayout(
                new Object[]{
                        OpsTables.OPS_TASK_STEP.STATUS,
                        OpsTables.OPS_TASK_STEP.NAME,
                }
        );

        cfg.view().field(OpsTables.OPS_TASK_STEP.UPDATE_BY).table().disable(true);
        cfg.view().field(OpsTables.OPS_TASK_STEP.UPDATE_BY).table().disable(true);
        cfg.view().field(OpsTables.OPS_TASK_STEP.CREATE_BY).table().disable(true);
        cfg.view().field(OpsTables.OPS_TASK_STEP.OPER_ID).table().disable(true);
        cfg.view().field(OpsTables.OPS_TASK_STEP.TASK_ID).table().disable(true);
        cfg.view().field(OpsTables.OPS_TASK_STEP.NOTES).table().disable(true);

        cfg.view().search().labelWidth(1,Config.searchLabelWidth);
        cfg.view().search().labelWidth(2,Config.searchLabelWidth);
        cfg.view().search().labelWidth(3,Config.searchLabelWidth);
        cfg.view().search().labelWidth(4,Config.searchLabelWidth);
        cfg.view().search().inputWidth(Config.searchInputWidth);
        cfg.view().field(OpsTables.OPS_TASK_STEP.STATUS).form().selectBox().enumType(OpsTaskStepStatusEnum.class);

        cfg.view().list().disableBatchDelete();


        cfg.view().formWindow().bottomSpace(60);
        cfg.view().formWindow().width(Config.baseFormWidth);
        cfg.view().form().addGroup(null,
                new Object[] {
                        OpsTables.OPS_TASK_STEP.NAME,
                        OpsTables.OPS_TASK_STEP.STATUS,
                        OpsTables.OPS_TASK_STEP.SDATE,
                        OpsTables.OPS_TASK_STEP.EDATE
                }
        );
        cfg.view().list().operationColumn().addActionButton("日志明细","detail","ops_task_log_detail");
        cfg.view().list().addJsVariable("TASK_ID","[[${taskId}]]","TASK_ID");
        //文件生成覆盖模式
        cfg.overrides()
                .setServiceIntfAnfImpl(WriteMode.COVER_EXISTS_FILE) //服务与接口
                .setControllerAndAgent(WriteMode.COVER_EXISTS_FILE) //Rest
                .setPageController(WriteMode.IGNORE) //页面控制器
                .setFormPage(WriteMode.COVER_EXISTS_FILE) //表单HTML页
                .setListPage(WriteMode.COVER_EXISTS_FILE)//列表HTML页
                .setExtendJsFile(WriteMode.IGNORE); //列表HTML页
        //生成代码
        cfg.buildAll();
    }

    public static void main(String[] args) throws Exception {
        TaskStepGtr g=new TaskStepGtr();
        //生成代码
        g.generateCode();
        //移除之前生成的菜单，视情况执行
        //g.removeByBatchId("478921035245158400");
       // g.generateMenu(DbDocServiceProxy.class, DbDocPageController.class);

     //   g.generateMenu(TaskStepServiceProxy.class, TaskStepPageController.class);
    }
}
